package com.smh.a06AplDemo6;

public class ZhiShu {
    public static void main(String[] args) {


        System.out.println(isZhi(7));
        System.out.println(isZiMi(153));
        int count=0;
        for (int i = 100; i < 1000; i++) {
            if (isZiMi(i)){
                count++;
            }
        }
        System.out.println(count);
        count=0;
        for (int i = 1000; i < 10000; i++) {
            if (isZiMi(i)){
                count++;
            }
        }
        System.out.println(count);
        count=0;
        for (int i = 10000; i < 100000; i++) {
            if (isZiMi(i)){
                count++;
            }
        }
        System.out.println(count);
        count=0;
        for (int i = 10; i < 100; i++) {
            if (isZiMi(i)){
                count++;
            }
        }
        System.out.println(count);

    }
    public static boolean isZhi(int a){
        for (int i = 2; i <= Math.sqrt(a); i++) {
            if (a%i==0){
                return false;
            }
        }
        return true;
    }
    public static boolean isZiMi(int a){
        String num = String.valueOf(a);
        //System.out.println(num);
        char[] chars = num.toCharArray();
        double sum = 0;
        int length = chars.length;
        for (int i = 0; i < chars.length; i++) {
            sum+=Math.pow((chars[i]-'0'),length);
        }
        if (sum==a){
            return true;
        }
        return false;
    }
}
